Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cert-manager plugin #143

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Add cert-manager plugin #143

wants to merge 1 commit into from

Conversation

yolossn
Copy link
Contributor

@yolossn yolossn commented Dec 30, 2024

Testing the Cert-Manager Plugin

Prerequisites

  • A Kubernetes cluster with cert-manager installed
  • Node.js and npm installed on your system

Steps to Test

  1. Clone the plugins repository:

    git clone https://github.com/headlamp-k8s/plugins.git
  2. Switch to the cert-manager branch:

    git checkout cert-manager
  3. Navigate to the cert-manager plugin directory:

    cd cert-manager
  4. Install the required dependencies:

    npm install
  5. Start the plugin in development mode:

    npm run start
  6. Launch Headlamp. You should now see "Cert Manager" in the sidebar.

Optional: Generate Cert-Manager Types

To test the plugin with sample cert-manager resources:

  1. Navigate to the test-files directory:

    cd test-files
  2. Apply the sample configurations to your cluster:

    kubectl apply -f clusterIssuer.yaml
    kubectl apply -f issuer.yaml
    kubectl apply -f certificate.yaml
    kubectl apply -f order.yaml
    kubectl apply -f app.yaml

This will create:

  • A ClusterIssuer for Let's Encrypt staging
  • An Issuer for Let's Encrypt staging
  • Two Certificate resources (one using ClusterIssuer, one using Issuer)
  • An Order resource
  • Sample Nginx deployment with Ingress configurations

Demo

cert-manager.mp4

@yolossn yolossn force-pushed the cert-manager branch 2 times, most recently from edef4f5 to b8ebea9 Compare December 30, 2024 08:45
@yolossn yolossn marked this pull request as ready for review January 19, 2025 13:52
@yolossn yolossn requested a review from a team January 19, 2025 13:55
@juv
Copy link

juv commented Jan 24, 2025

This is great 👍

Copy link
Contributor

@joaquimrocha joaquimrocha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a couple of small comments. The plugin should also display a special error if the cert-manager is not installed.

cert-manager/README.md Outdated Show resolved Hide resolved
cert-manager/package.json Outdated Show resolved Hide resolved
},
{
label: 'Last Transition Time',
getter: item => item.lastTransitionTime,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the DateLabel component here:
Screenshot showing dates in ISO format

cert-manager/src/index.tsx Outdated Show resolved Hide resolved
Signed-off-by: yolossn <sannagaraj@microsoft.com>
@yolossn
Copy link
Contributor Author

yolossn commented Jan 30, 2025

image

Addressed the comments and added cert-manager not detected banner.

Copy link
Contributor

@knrt10 knrt10 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work @yolossn. Apart from some suggestions, everything looks great

cert-manager/.gitignore Show resolved Hide resolved
cert-manager/README.md Show resolved Hide resolved
cert-manager/package.json Show resolved Hide resolved
cert-manager/README.md Show resolved Hide resolved
cert-manager/README.md Show resolved Hide resolved
columns={[
{
label: 'Class',
getter: item => item.ingress.class,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same, please fix the object scope

columns={[
{
label: 'Class',
getter: item => item.ingress.class,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same please edit scope


<IconButton
onClick={() => {
navigator.clipboard.writeText(item.spec.request);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same, please check for errors here

};
key: string;
solver: {
http01: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

according to cert-manager docs, should we also add for dns01?

static kind = 'Order';
static apiName = 'orders';
static apiVersion = ['acme.cert-manager.io/v1'];
static isNamespaced = false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these are namespaced resource

Suggested change
static isNamespaced = false;
static isNamespaced = true;

Copy link
Contributor

@sniok sniok left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good stuff! left a couple of comments

{
id: 'approved',
label: 'Approved',
getValue: certificateRequest => certificateRequest.approved,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for simple cases like this, it's better to use datum field like so:

 {
   id: 'approved',
   label: 'Approved',
   datum: 'approved',
}

import { NotInstalledBanner } from '../common/NotInstalledBanner';

export function CertificateRequestsList() {
const [isManagerInstalled, setIsManagerInstalled] = useState(false);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this part (useState + useEffect) is repeated in each List component. please extract it into a it's own hook.

this starts with value false which will render NotInstalledBanner by default, even if it is installed. I'd recommend adding additional field isManagerCheckLoading that will keep track whether the check is still loading. this will avoid flashing "NotInstalledBanner"

also this check is loaded every time you enter the page, it should be fetched once and remember the value

});

// 1. certificates.cert-manager.io
registerSidebarEntry({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this pattern repeats here, registerSidebarEntry + registerRoute for Details and List could be put in a function

export class Certificate extends KubeObject<CertManagerCertificate> {
static kind = 'Certificate';
static apiName = 'certificates';
static apiVersion = ['cert-manager.io/v1'];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

apiVersion can be just a string, no need for an array here

@@ -0,0 +1,12 @@
import { ApiProxy } from '@kinvolk/headlamp-plugin/lib';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this file could be named isCertManagerInstalled since there's nothing else here

@@ -0,0 +1,58 @@
import { KubeObject } from '@kinvolk/headlamp-plugin/lib/k8s/cluster';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/types/ folder name is a bit misleading. types usually means only typescript type definitions, here we define classes. Maybe /model/ would be better?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

5 participants